package com.crm.controller.common;

import com.crm.common.result.ResultVO;
import com.crm.common.utils.OssUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
//@RequestMapping("/common")
@Slf4j
@Api(tags = "通用接口")
public class CommonController {
   /* @Autowired
    private OssUtil aliOssUtil;

    @PostMapping("/upload")
    @ApiOperation("文件上传")
    public ResultVO<String> uploadFile(MultipartFile file) {

        log.info("文件上传开始");
        log.info("文件名：" + file.getOriginalFilename());
        try {
            // 使用uploadMultipartFile方法处理MultipartFile对象
            String uploadedPath = aliOssUtil.uploadMultipartFile(file);
            return ResultVO.success(uploadedPath);
        } catch (Exception e) {
            log.error("文件上传失败", e);
            throw new RuntimeException("文件上传失败", e);
        }

    }*/

    /**
     * 生成OSS路径（使用正斜杠）
     */
 /*   private String generateOssPath(String originalFilename) {
        LocalDateTime now = LocalDateTime.now();
        String format = now.format(DateTimeFormatter.ofPattern("yyyy/MM/dd"));
        String suffixName = originalFilename.substring(originalFilename.lastIndexOf("."));

        return format + "/" + UUID.randomUUID().toString() + suffixName;
    }*/
}